<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<%@ include file="/commons/head.jsp" %>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <%@ include file="/commons/left.jsp" %>
    <div class="content-wrapper">
        <section class="content-header">
            <h1>
                友情链接信息
            </h1>
        </section>
        <div class="content">
            <div class="row">
                <div class="col-md-9">
                    <div class="box box-primary" style="overflow:hidden">
                        <form id="postForm" enctype="multipart/form-data" class="form-horizontal" method="post" autocomplete="off">
                            <input type="hidden" name="id" value="${entity.id}">
                            <div class="box-body" style="padding-top:30px">
                                <div class="form-group">
                                    <label for="inputSiteName" class="col-sm-2 control-label">站点名称：</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control" autocomplete="off" id="inputSiteName"
                                               name="siteName" value="${entity.siteName}" placeholder="请输入站点名称">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputSiteName" class="col-sm-2 control-label">站点链接：</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control" autocomplete="off" id="inputSiteUrl"
                                               name="siteUrl" value="${entity.siteUrl}" placeholder="请输入站点链接">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="multipartFile" class="col-sm-2 control-label">站点LOGO</label>
                                    <div class="col-sm-5"><input id="multipartFile"  name="multipartFile" type="file"  accept="image/*"
                                                                 style="margin-top: 5px;"></div>
                                </div>
                            </div>
                            <div class="box-footer">
                                <div class="col-sm-2"></div>
                                <button type="button" class="btn btn-info" onclick="submitForm()">提交</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <%@ include file="/commons/script.jsp" %>
    <script type="text/javascript" src="${ctx}/dist/js/jquery.form.js"></script>
    <script type="text/javascript">
        function submitForm() {
            var id = $('#postForm').find('input[name=id]').val();
            var url = null;
            if (id == null || id == "") {
                url = "${ctx}/friend/saveFriendUrl?action=add";
            } else {
                url = "${ctx}/friend/saveFriendUrl?action=update";
            }
            $("#postForm").ajaxSubmit({
                cache: false,
                type: "post",
                url: url,
                success: function(data) {
                    if(data == 1){
                        //添加成功
                        alert("成功");
                        window.location.href = "${ctx}/friend/listFriendUrl";
                    }else{
                        alert("失败");
                    }
                },
                error: function() {
                    alert("系统异常");
                }
            });
            <%--$.ajax({--%>
                <%--cache: false,--%>
                <%--type: "post",--%>
                <%--url: url,--%>
                <%--data: $('#postForm').serialize(),// formid--%>
                <%--error: function () {--%>
                    <%--alert("系统异常");--%>
                <%--},--%>
                <%--success: function (data) {--%>
                    <%--if (data !== null) {--%>
                        <%--if (data == 0) {--%>
                            <%--//修改失败--%>
                            <%--alert('失败');--%>
                        <%--} else {--%>
                            <%--//添加/修改成功--%>
                            <%--alert('成功');--%>
                            <%--window.location.href = "${ctx}/friend/listFriendUrl";--%>
                        <%--}--%>
                    <%--}--%>
                <%--}--%>
            <%--});--%>
        }
    </script>
</body>
</html>
